    
<template>
	
<view class="app">
	
	
	<!-- 包括个人 开卡 三个课时 -->
  <view class="top">
	  
	  
	<!-- 个人 -->
    <view class="title-box">
      <view class="mine">
	      <view class="name">你好, {{ coachInformation.name }}</view>
	      <view class="name-icon">{{ coachInformation.name }}</view>
      </view>
    </view>
	
	  <!--开卡部分-->
	  <view class="time">
		<view class="time-box">
		  <view class="card-title">本月完成课场：{{ coachInformation.coachCountM + coachInformation.coachCountS }}(主教:{{ coachInformation.coachCountM }},助教:{{ coachInformation.coachCountS }})</view>
		</view>
	  </view>
	
    <view class="contain">
		<view class="contain-box">
			
			<view class="item">
				<view class="cent">
					<view class="number">{{ coachInformation.todayCount }}</view>
					<view>今天剩余课场</view>
				</view>
			</view>
			
			<view class="line"></view>
			
			<view class="item"><view class="cent">
				<view class="number">5</view><view>本月签到次数</view></view>
			</view>
			<view class="line"></view>
			<view class="item" @click="ondetail">
				<view class="cent"><view class="number">{{ coachInformation.totalCount }}</view><view>总课场</view><view>(点击详细)</view></view>
			</view>
		</view>
    </view>
	
  </view>
  
  
  <!-- 主要服务 -->
  
  <view class="services">
	  
	<view class="services-section">
  
    <view class="section-header">
      <text class="section-title">主要服务</text>
    </view>
	
    <view class="services-grid">
      <view class="service-item" @click="ToSchedule">
        <image class="service-icon" src="/imgs/课表.png" mode="aspectFit"/>
        <text class="service-name">课表</text>
      </view>
  
      <view class="service-item" @click="ToHomework">
        <image class="service-icon" src="/imgs/课后作业2.png" mode="aspectFit"/>
        <text class="service-name">课后作业</text>
      </view>
  
      <view class="service-item" @click="ToTeacherReview">
        <image class="service-icon" src="/imgs/评价老师.png" mode="aspectFit"/>
        <text class="service-name">评价老师</text>
      </view>
  
      <view class="service-item" @click="ToGrowthRecord">
        <image class="service-icon" src="/imgs/成长档案.png" mode="aspectFit"/>
        <text class="service-name">成长档案</text>
      </view>
  
      <view class="service-item" @click="ToCourses">
        <image class="service-icon" src="/imgs/课程5.png" mode="aspectFit"/>
        <text class="service-name">课程</text>
      </view>
  
      <view class="service-item" @click="ToClassReview">
        <image class="service-icon" src="/imgs/课堂点评.png" mode="aspectFit"/>
        <text class="service-name">课堂点评</text>
      </view>
  
      <view class="service-item" @click="ToClassRecord">
        <image class="service-icon" src="/imgs/上课记录.png" mode="aspectFit"/>
        <text class="service-name">上课记录</text>
      </view>
  
      <view class="service-item" @click="ToBookClass">
        <image class="service-icon" src="/imgs/约课.png" mode="aspectFit"/>
        <text class="service-name">约课</text>
      </view>
    </view>
  </view>
  
  <!-- 其他服务 -->
   <view class="services-section">
  
    <view class="section-header">
      <text class="section-title">其他服务</text>
    </view>
    <view class="services-grid">
      <view class="service-item" @click="ToLeave">
        <image class="service-icon" src="/imgs/请假2.png" mode="aspectFit"/>
        <text class="service-name">请假</text>
      </view>
  
      <view class="service-item" @click="ToPointsGift">
        <image class="service-icon" src="/imgs/积分礼品.png" mode="aspectFit"/>
        <text class="service-name">积分礼品</text>
      </view>
  
      <view class="service-item" @click="ToOnlineStore">
        <image class="service-icon" src="/imgs/在线商城.png" mode="aspectFit"/>
        <text class="service-name">在线商城</text>
      </view>
  
    </view>
  </view>
  </view>
  


  
  
  <!--今日课表部分-->
  
    <view class="today-course">
		
	  <view class="today-course-title">今日课表</view>
		
      <view v-for="item in courseList" key="item.id" class="today-course-box">
		  
		  <view class="course-header">
		  	<view class="course-name">{{ item.name }}</view>
		  	<view class="course-time">{{ item.startTime }} - {{ item.endTime }}</view>
		  </view>
		  
		  <view class="course-details">
		  	<view class="course-teacher">课程老师：{{ item.coachM.name }}</view>
		  	<view class="course-room">上课教室：{{ item.site }}</view>
		  </view>
		  
		  <view class="attendance">
			<view v-if="item.coachListS.length === 0" class="course-teacher">助教：无</view>
		  	<view v-else class="course-teacher">助教：{{ item.coachListS.map(row => row.name).join(',') }}</view>
		  	<!-- <button class="call-button">去点名</button> -->
			<view class="call-button" v-if="item.state === 1" @click="goCallStudent(item.id)">去点名</view>
			<view class="call-no-button" v-else-if="item.state === 0">未开始</view>
			<view class="call-no-button" v-else>已点名</view>
		  </view>
		  
	  </view>
	  
	  
	  
    </view>
	
<!-- 	<view class="today-course">
	  <view class="today-course-box">
		  <view class="course-header">
		  	<view class="course-name">L5跑酷</view>
		  	<view class="course-time">09:30 - 10:30</view>
		  </view>
		  <view class="course-details">
		  	<view class="course-teacher">课程老师：葡萄</view>
		  	<view class="course-room">上课教室：2号教室</view>
		  </view>
		  <view class="attendance">
		  	<view class="attendance-text">已点名：0/0</view>
		  	<view class="call-button">去点名</view>
		  </view>
	  </view>
	</view> -->
	
	
	<view class="bottom-nav">
		<view class="nav-item">
		  <image class="nav-icon" src="/imgs/首页.png"></image>
		  <text class="nav-text">首页</text>
		</view>
		<view class="nav-item" @click="ToMy">
		  <image class="nav-icon" src="/imgs/我的.png"></image>
		  <text class="nav-text">我的</text>
		</view>
	</view>
	
</view>



<!--弹窗-->
<view v-if="flag" class="tap" @click="ondetail">
  <view class="tap-conain"><view>总课时：</view> <view>（包含购买课时：+免费课时：）</view></view>
</view>

</template>

<script setup>
import { ref,onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { getCoachInformation,getTodayCourse } from '@/api/index.js'
import { showLoading } from '@/utils/showLoading';

const coachInformation = ref({})
const courseList = ref([])

onMounted(() =>{
	showLoading()
	Promise.all([getCoachInformation(),getTodayCourse()])
	.then(([resCoach,resCourse]) => {
		coachInformation.value = resCoach.data
		courseList.value = resCourse.data
		uni.hideLoading()
	})
	
	// getCoachInformation().then(res =>{
	// 	coachInformation.value = res.data
	// 	console.log("主页返回教练信息内容",coachInformation.value)
	// })
	// getTodayCourse().then(res => {
	// 	courseList.value = res.data
	// 	console.log("主页返回今日课程内容",courseList.value)
	// })
})


//页面跳转开开始
// 课表
const ToSchedule = () => {
	uni.navigateTo({
		url: "/pages/schedule/index"
	})
}

// 课后作业
const ToHomework = () => {
	uni.navigateTo({
		url: "/pages/homework/index"
	})
}

// 评价老师
const ToTeacherReview = () => {
	uni.navigateTo({
		url: "/pages/teacher-review/index"
	})
}

// 成长档案
const ToGrowthRecord = () => {
	uni.navigateTo({
		url: "/pages/growth-record/index"
	})
}

// 课程
const ToCourses = () => {
	uni.navigateTo({
		url: "/pages/courses/index"
	})
}

// 课堂点评
const ToClassReview = () => {
	uni.navigateTo({
		url: "/pages/class-review/index"
	})
}

// 上课记录
const ToClassRecord = () => {
	uni.navigateTo({
		url: "/pages/class-record/index"
	})
}

// 约课
const ToBookClass = () => {
	uni.navigateTo({
		url: "/pages/book-class/index"
	})
}



// 请假
const ToLeave = () => {
	uni.navigateTo({
		url: "/pages/leave/index"
	})
}

// 积分礼品
const ToPointsGift = () => {
	uni.navigateTo({
		url: "/pages/points-gift/index"
	})
}

// 在线商城
const ToOnlineStore = () => {
	uni.navigateTo({
		url: "/pages/online-store/index"
	})
}

// 消费
// const CheckConsume = () => {
// 	uni.navigateTo({
// 		url: "/pages/consumeLog/index"
// 	})
// }

// 
function goCallStudent(id){
	uni.setStorageSync("courseId",id)
	uni.navigateTo({
		url: "/pages/callStudent/index"
	})
}
// 我的
const ToMy = () => {
	uni.navigateTo({
		url: "/pages/my/index"
	})
}










//页面跳转结束
const ondetail = () => {
	flag.value = !flag.value
}


</script>













<style>
page{
  background-color: #f6f6f6;
  /* 底部导航条高度 */
  padding-bottom: 80rpx; 
  
}


/* <!--弹窗--> */
.tap{
  position: fixed;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background-color: rgba(128, 128, 128, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
}
.tap .tap-conain{
  height: 150rpx;
  width: 700rpx;
  background-color: white;
}
.tap .tap-conain view{
  width: 100%;
  display: flex;
  justify-content: center;
  font-size: 20px;
  margin-top:15rpx ;
  font-family: 'Courier New', Courier, monospace;
}






/* 头部 */
.top {
/*  width: 100%;
  height: 500rpx;
  border-radius: 0% 0% 10% 10%;
  position: relative;
  overflow: hidden;
  z-index: 1; */
  
  padding: 25px;
  background: linear-gradient(to right, #ff7e5f, #feb47b);
  color: white;
  border-radius: 0% 0% 5% 5%;
  margin-bottom: 3%;
}
/* 
.top::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  transform: rotate(-15deg);
  background: #f95d41;
	z-index: -1;
  pointer-events: none;
} */


.top .mine{
/*  width: 100%;
  height: 50%;
  display: flex;
  flex-direction: column; 
  justify-content: center;
              align-items: flex-start;
  font-family: 'Courier New', Courier, monospace;
  font-family: 'Dancing Script', cursive;
  font-size: 25px;
  color:black; */
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.title-box .name{
	font-size: 1.3rem;
	font-weight: 600;
}
.title-box .name-icon{
	width: 45px;
	height: 45px;
	border-radius: 50%;
	background: #fff;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ff7e5f;
	font-weight: bold;
}



/* 卡的有效期 */
.time{
	background: rgba(255, 255, 255, 0.2);
	border-radius: 10px;
	padding: 10px;
	/* margin-bottom: 15px; */
}

.time .time-box .card-title{
  display: flex;
  justify-content: center;
  align-items: center;
}
.time .time-box .card-time{
  margin-left: 15rpx;
  width: 100%;
  height: 70rpx;
}





/* 课时部分 */
/* 三个课时  竖线隔开 */

.contain .contain-box{
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  
}
/* .contain .line{
	height: 80%;
	width: 1rpx;
	background-color: #cccccc;
	
} */
.contain .item{
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px;
  flex: 1;
  margin: 0 5px;
  text-align: center;
}
.contain .number{
	font-size: 1.2rem;
	font-weight: 600;
	margin-bottom: 5px;
}

.contain .lessons{
	font-size: 0.8rem;
	opacity: 0.9;
}


/* 字体 */
/* .contain .item .cent view{
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  color:black;
  font-family: 'Courier New', Courier, monospace;
  font-family: monospace;
}
.contain .item .number{
  font-size: 30px;
  margin-bottom: 5rpx;
} */







/* 服务 整块卡片 */
.services{
	margin-left: 3%;
	width: 94%;
	display: flex;
	flex-direction:column;
	justify-content: center;
  /* background: #ff4fff; */
}
.services-section {
  /* width: 94%; */
  /* margin: 0 auto; */
  background: #fff;
  /* background: #46ff3d; */
  border-radius: 20rpx;
  /* padding: 40rpx 30rpx; */
  padding: 20rpx;
  margin-bottom: 20rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  
  
  
}

/* 头部 */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}
.section-title {
  font-size: 30rpx;
  font-weight: 600;
  color: #2c3e50;
  position: relative;
  padding-left: 20rpx;
}
/* 左边的橙色竖线 */
.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 32rpx;
  width: 8rpx;
  background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
  border-radius: 8rpx;
}

/* 网格 */
.services-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20rpx;
  
  /* background: #3d5aff; */
  
}
.service-item {
  /* background: rgba(255, 255, 255, 0.9); */
  
  /* background: rgba(255, 200, 33, 0.9); */
  border-radius: 32rpx;
  padding: 18rpx 0;
  text-align: center;
  /* box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.06); */
  /* transition: all 0.3s ease; */
  position: relative;
  overflow: hidden;
  /* border: 1rpx solid #f0f0f0; */
}



/* 图标 */
.service-icon {
	/* 
  width: 40rpx;
  height: 40rpx; */
  width: 45rpx;
  height: 45rpx;
  margin: 0 auto 20rpx;
  display: block;
  transition: all 0.3s ease;
  /* background: #f4f4f4; */
  background: #f5f5f5;
  padding:10px;
  border-radius: 18px;
}


/* 文字 */
.service-name {
  /* font-size: 26rpx; */
  font-size: 22rpx;
  color: #444;
  font-weight: 500;
}







/* 今日课表 */
.today-course{
	width: 94%;
	display: flex;
	flex-direction:column;
	justify-content: center;
	/* align-items: center; */
	/* background-color: #5f9c93; */
	margin-left: 3%;
}
/* 今日课表 条 */
.today-course-title{
  font-size: 30rpx;
	font-weight: 600;
  color: #2c3e50;
  position: relative;
  padding-left: 20rpx;
  margin-bottom: 20rpx;
  /* 
	margin: 20px 0 15px;
	padding-left: 10px; */
	/* border-left: 4px solid #fe8b64; */
	/* background-color: #495057; */
}
/* 左边的橙色竖线 */
.today-course-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 32rpx;
  width: 8rpx;
  background: linear-gradient(135deg, #ff7e5f 0%, #feb47b 100%);
  border-radius: 8rpx;
}

/* 今日课表 内容 */
.today-course-box{
	background: white;
	border-radius: 15px; 
	padding: 20px;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
	margin-bottom: 15px;
}
/* 时间 */
.course-header{
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 15px;
    color: #6c757d;
}
/* l4 */
.course-name{
	color: #fe8b64;
	font-size: 30rpx;
    font-weight: 560;
    /* color: #ffe410; */
}
/* 第二行 */
.course-details {
    display: grid;
	grid-template-columns: 1fr 1fr;
	margin-bottom: 15px;
    /* color: #ffe410; */
}

.attendance {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* color: #ffe410; */
    }
/* 已点名：0/0 */
.attendance-text {
    font-size: 15px;
    color: #000000;
    /* font-weight: 600; */
    color: #878a96;
}
/* 去点名按钮 */
.call-button {
    background: #fee9da;
    color: #fe8b64;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
/* 未激活状态*/
.call-no-button {
    background: #b2b6bf;
    color: #ffffff;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}
/* 底部条 */
	.bottom-nav {
	  position: fixed;
	  bottom: 0;
	  width: 100%;
	  /* max-width: 900rpx; */
	  display: flex;
	  background: #fff;
	  border-top: 2rpx solid #eee;
	  padding: 10rpx 0;
	}
	
	.nav-item {
	  flex: 1;
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	  justify-content: center;
	  color: #888;
	  font-size: 24rpx;
	}
	
	.nav-item.active {
	  color: #ff9a9e;
	}
	
	.nav-icon {
	  width: 34rpx;
	  height: 34rpx;
	  margin-bottom: 6rpx;
	}
.nav-text{
	font-size: 22rpx;
}

		
</style>

 